using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Collections;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Serialization.Formatters;

using MULENetworking;

namespace MULEServer
{
    class ChatServer
    {
        private TcpChannel tcpChan;
        private int tcpPort = 9887;

        public ChatServer()
        {
            BinaryClientFormatterSinkProvider clientProvider = null;
            BinaryServerFormatterSinkProvider serverProvider =
               new BinaryServerFormatterSinkProvider();

            serverProvider.TypeFilterLevel =
                System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            IDictionary props = new Hashtable();
            props["port"] = tcpPort;
            props["typeFilterLevel"] = TypeFilterLevel.Full;
            tcpChan = new TcpChannel(
                props, clientProvider, serverProvider);

            ChannelServices.RegisterChannel(tcpChan, false);

        }

        public void StartServer()
        {
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteServer),
                            "MULEServer",
                            WellKnownObjectMode.Singleton);
        }

    }
}
